<#assign contextPath=springMacroRequestContext.getContextPath() />
<#import "/public/frame/main.html" as frame />
<@frame.head "南航明珠商城-用户列表">
</@frame.head>

<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 后台管理中心 <span class="c-gray en">&gt;</span> 商品管理 <span class="c-gray en">&gt;</span> 商品问答设置 <a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="${contextPath}/productQuestionsAnswersSetting/questions_Setting_info" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
    <head>

        <style>
            .monitor tr td {
                height:40px;
                text-indent: 2em;
            }
            
            .monitor tr td input{
                width: 50px;
            }
            
            .monitor_td{
                text-indent: 0px !important;
            }
            
            .monitor_log{
            height:50px;
            line-height: 50px;
            text-indent:2em;
            }
        </style>        
    </head>
    <body>
        
                    <div id="main_content" class="fl">
                        <div class="monitor_info">
                            <div class="filter">
   
                                <form method="post" name="query_setting_form"  id="query_setting_form" action="${contextPath}/productQuestionsAnswersSetting/modifySetting" >    
                                 <div style="border-bottom: 1px solid #ddd;">
                                       <b style="font-size: 16px;">商品问答设置：</b>
                                 </div>
                                <table style="margin-top: 20px;" class="monitor">

                                    <tr >
                                       <td>
                                        <select onchange="change()" id="status" name="status">
                                        <option <#if productQuestionsAnswersSetting.status == 1> selected = "selected" </#if> value="1" >开启
                                        </option>
                                        <option value="0" <#if productQuestionsAnswersSetting.status != 1> selected = "selected" </#if> >关闭
                                        </option>
                                        </select>商品咨询
                                        
                                        <label class="typechange"><input type="checkbox" name="type1" value="1" <#if productQuestionsAnswersSetting.type1 == 1> checked="checked" </#if> />实物商品 </label> 
										<label class="typechange"><input name="type2" type="checkbox" value="1" <#if productQuestionsAnswersSetting.type2 == 1> checked="checked" </#if> />虚拟商品 </label> 
										<label class="typechange"><input name="type3" type="checkbox" value="1" <#if productQuestionsAnswersSetting.type3 == 1> checked="checked" </#if> />机票优惠券</label> 
										<label class="typechange"><input name="type4" type="checkbox" value="1" <#if productQuestionsAnswersSetting.type4 == 1> checked="checked" </#if> />其他-购票资质</label> 
										<label class="typechange"><input name="type5" type="checkbox" value="1" <#if productQuestionsAnswersSetting.type5 == 1> checked="checked" </#if> />其他-升舱资质 </label> 
										
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                        <select onchange="promptShow()" id="openPrompt" name="openPrompt" class="openPrompt">
                                        <option value="1" <#if productQuestionsAnswersSetting.openPrompt == 1> selected = "selected" </#if> >显示
                                        </option>
                                        <option value="0" <#if productQuestionsAnswersSetting.openPrompt != 1> selected = "selected" </#if> >隐藏
                                        </option>
                                        </select>提示语
                                        
                                        
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                        <textarea rows="6" cols="100" name="prompt" class="prompt" >${productQuestionsAnswersSetting.prompt}</textarea>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                       <input type="checkbox"  name="openConsultationLimit"  id="box" value="1" <#if productQuestionsAnswersSetting.openConsultationLimit == 1> checked="checked" </#if> />
                                                每个会员每日咨询上限<input name="consultationLimit" id="hours" value="${productQuestionsAnswersSetting.consultationLimit}" onkeyup="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}" onafterpaste="if(this.value.length==1){this.value=this.value.replace(/[^1-9]/g,'')}else{this.value=this.value.replace(/\D/g,'')}">
                                            
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                       <input type="checkbox"  name="openSensitiveWords"  id="box" value="1" <#if productQuestionsAnswersSetting.openSensitiveWords == 1> checked="checked" </#if> />
                                                启用敏感词汇库&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" style="width: 90px" class="btn btn-primary radius"  value="敏感词汇库 " onclick="setWords()"/>
                                            
                                        </td>
                                    </tr>
                                   <tr>
                                        <td>
											商品咨询分类设置：
										<select onchange="changeType()" id="classifiedType" class="classifiedType">
										<option  value="0">请选择商品类型
                                        </option>
                                        <option  value="1">实物商品
                                        </option>
                                        <option value="2"  >虚拟商品
                                        </option>
                                        <option value="3"  >机票优惠券
                                        </option>
                                        <option value="4"  >其他-购票资质
                                        </option>
                                        <option value="5"  >其他-升舱资质
                                        </option>
                                        </select>
                                        </td>
                                    </tr>
                                    <tr>
                                    <td>
                                    <div id="classifiedConsultation" class="classifiedConsultation" style="display:none;">
                                    <div style="float :left; " >
                                    <input type="text" style="border:1px solid #000 ;width:144px;height:176px; padding:1px;" id="typeName" class="typeName">
                                    
                                    </div>
                                    <div style="width:80px;height:180px;float :left; ">
                                     <ul>
                                     <li>
                                     <a href="javascript:void(0)" onclick="add()"><svg class="icon" style="width: 3em; height: 3em;vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="463"><path d="M512 832c-176.448 0-320-143.552-320-320S335.552 192 512 192s320 143.552 320 320-143.552 320-320 320m0-704C300.256 128 128 300.256 128 512s172.256 384 384 384 384-172.256 384-384S723.744 128 512 128M683.936 470.944H544v-139.968a32 32 0 1 0-64 0v139.968h-139.936a32 32 0 0 0 0 64H480v139.968a32 32 0 0 0 64 0v-139.968h139.968a32 32 0 0 0 0-64" p-id="464"></path></svg> </a> 
                                     </li><br>
                                     <li>
                                     <a href="javascript:void(0)" onclick="delType()"><svg class="icon" style="width: 3em; height: 3em;vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="1323"><path d="M512 832c-176.448 0-320-143.552-320-320S335.552 192 512 192s320 143.552 320 320-143.552 320-320 320m0-704C300.256 128 128 300.256 128 512s172.256 384 384 384 384-172.256 384-384S723.744 128 512 128M645.536 473.6h-256a32 32 0 0 0 0 64h256a32 32 0 0 0 0-64" p-id="1324"></path></svg> </a>
                                     </li><br>
                                     <li>
                                     <a href="javascript:void(0)" onclick="editType()"><svg class="icon" style="width: 3em; height: 3em;vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="553"><path d="M766.88 435.264l-176.608-176.64 66.72-66.752 176.544 176.704-66.656 66.688zM401.44 800.96L224.64 624.192l0.256 0.064L545.024 303.904l176.64 176.64L401.376 800.96zM224 801.92v-87.872l87.712 87.68-87.68 0.192z m655.04-478.528l-176.768-176.736A60.96 60.96 0 0 0 656.96 128a63.968 63.968 0 0 0-45.12 18.848L179.584 579.008a63.936 63.936 0 0 0-17.92 54.368c-0.768 2.688-1.696 5.312-1.696 8.256v160.288c0 35.136 28.576 63.68 63.712 63.68h160.32c2.88 0 5.504-0.896 8.192-1.632 2.976 0.416 5.952 0.832 8.96 0.832 16.416 0 32.896-6.272 45.44-18.816l432.16-432.16a64 64 0 0 0 0.224-90.432z" p-id="554"></path></svg> </a>
                                     </li>
                                     <li>
                                     <a href="javascript:void(0)" onclick="showhide()"><svg id="shows" class="icon" style="width: 3em; height: 3em;vertical-align: middle;fill: currentColor;overflow: hidden;" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="533"><path d="M376.16 551.936v-71.872a128.16 128.16 0 0 1 128-128.064c70.592 0 128 57.44 128 128.064v71.872a128.16 128.16 0 0 1-128 128.064c-70.592 0-128-57.44-128-128.064m494.88-80.96c-2.048-4.704-26.72-59.936-78.88-116.928C733.696 290.144 640.576 224 504.16 224s-229.6 66.24-288 130.016c-52.096 56.864-76.608 111.68-78.208 115.488-12.736 24.896-13.056 60.896-2.016 82.816 0.48 1.248 24.32 60.96 80.224 121.44 57.984 62.72 150.464 126.24 288 126.24 137.504 0 230.08-63.68 288-126.208 55.872-60.32 79.52-119.616 79.552-119.776 11.744-24.896 10.88-61.664-0.672-83.008" p-id="534"></path></svg></a>
                                     </li>
                                     </ul> 
                                     </div>
                                    <div style="border:1px solid #000 ;width:150px;height:180px;float :left; " >
                                     <ul class="typeUl" id="typeUl">
      
                                     </ul> 
                                    
                                    </div>
                                    </div>
                                    </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <input class="btn btn-success radius"  type="submit" value="修改"/>
                                        </td>
                                    </tr>
                                </table>
                                </form>
                            </div>
                            <div style="border-top: 2px solid #ddd;">
                                <table class="monitor_log">
                                    <tr>
                                        <td>
                                            最后修改人：${productQuestionsAnswersSetting.userName}
                                        </td>
                                        <td>
                                            修改时间：
                                            ${(productQuestionsAnswersSetting.lastTime?string("yyyy-MM-dd HH:mm:ss"))!}
                                        </td>
                                    </tr>
                                </table>
                            </div>
                        </div>
                    </div>
                    <div class="clear"></div>
                        
                    </div>
                
                
                
                            </div>
            </div>
 
</body>
<@frame.end "default">
</@frame.end>
<script type="text/javascript" src="${contextPath}/resources/js/jquery-1.3.2.min.js"></script>
<script type="text/javascript" src="${contextPath}/resources/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="${contextPath}/resources/js/laypage/laypage.js"></script>

<script>
var path="${contextPath}";
$(function(){  
    	var status=$("#status").val();
	if(status==0){
		$(".typechange").hide();
	}else{
		$(".typechange").show();
	}
	 	var status=$("#openPrompt").val();
	if(status==0){
		$(".prompt").hide();
	}else{
		$(".prompt").show();
	}
}); 
   var oBox= document.getElementById('box');
  oBox.onclick =function(){
     if(this.checked){
         document.getElementById("hours").disabled = false;
} else{
     document.getElementById('hours').value="";
     document.getElementById("hours").disabled = true;
  }
}
function change(){
	var status=$("#status").val();
	if(status==0){
		$(".typechange").hide();
	}else{
		$(".typechange").show();
	}
	   
}
function promptShow(){
	var status=$("#openPrompt").val();
	if(status==0){
		$(".prompt").hide();
	}else{
		$(".prompt").show();
	}
	   
}
function add(){
	var type=$("#classifiedType").val();
	var typeName=$("#typeName").val();
	if(type==0){
	alert("请选择商品类型!");
	return;
	}
		$.ajax({
		url:path+"/productQuestionsAnswersSetting/add_classifiedConsultation",
		type:"post",
		dataType:"text",
		data:{"type":type,"typeName":typeName},
		error:function(XMLHttpRequest, textStatus, errorThrown){
       		
		},
		success:function(msg) 
		{
		if(msg=='false'){
		
		}else{
		changeType();
		}
		
           }
		});
}
var chosseId;
function changeType(){
	var type=$("#classifiedType").val();
	if(type==0){
	$(".classifiedConsultation").hide();
	}else{
		$.ajax({
		url:path+"/productQuestionsAnswersSetting/list_classifiedConsultation",
		type:"post",
		dataType:"text",
		data:{"type":type},
		error:function(XMLHttpRequest, textStatus, errorThrown){
       		
		},
		success:function(msg) 
		{

		 	$("#typeUl").empty();
 			$("#typeUl").html(msg);
			$(".classifiedConsultation").show();

           }
		});
	$(".classifiedConsultation").show();
	}
}
//设置敏感词汇库
function setWords(){
	
	
	 layer.open({
	        type: 2,
	        title: "设置敏感词汇库",
	        scrollbar: false,
	        content:'${contextPath}/productQuestionsAnswersSetting/to_add_sensitiveWords',
	        area: ['520px', '350px']
	    });

}	
function g(x)
	{ 			chosseId=x;
			d=document.getElementsByTagName('li')
			for(p=d.length;p--;){
			if(d[p].id!=x){
			d[p].style.backgroundColor='';
			d[p].setAttribute('class','');
			}
			else{
			d[p].style.backgroundColor='rgb(43, 221, 189)';
			d[p].setAttribute('class','chekedClass');
			}
			}
			var show=$("#"+x).attr("value");
			if(show=="1"){
				$("#shows").css('fill','currentColor');
			}else{
				$("#shows").css('fill','blue');
			}
	}
function delType(){
	var id=$(".chekedClass").attr("id");
	var type=$("#classifiedType").val();
	if(id=='undefined'){
	alert("请选择类型");
	return;
	}else{
		if(type==0){
	alert("请选择咨询分类");
	}
			$.ajax({
		url:path+"/productQuestionsAnswersSetting/is_del_classifiedConsultation",
		type:"post",
		dataType:"text",
		data:{"type":type,"typeId":id},
		error:function(XMLHttpRequest, textStatus, errorThrown){
       		
		},
		success:function(msg) 
		{
		if(msg=="false"){
				$.ajax({
		url:path+"/productQuestionsAnswersSetting/del_classifiedConsultation",
		type:"post",
		dataType:"text",
		data:{"type":type,"typeId":id},
		error:function(XMLHttpRequest, textStatus, errorThrown){
       		
		},
		success:function(msg) 
		{
		if(msg=="false"){
		alert("删除失败");
		}else{
			alert("删除成功");
			changeType();
		}
           }
		});
		}else{
		if(confirm("当前分类下已有咨询，删除该项后数据将丢失")){ 
							$.ajax({
		url:path+"/productQuestionsAnswersSetting/del_classifiedConsultation",
		type:"post",
		dataType:"text",
		data:{"type":type,"typeId":id},
		error:function(XMLHttpRequest, textStatus, errorThrown){
       		
		},
		success:function(msg) 
		{
		if(msg=="false"){
		alert("删除失败");
		}else{
			alert("删除成功");
			changeType();
		}
           }
		});
			} 
		}
           }
		});

	}
	
}
function editType(){
	var id=$(".chekedClass").attr("id");
	var name=$(".chekedClass").html();
	var type=$("#classifiedType").val();
	name=name.replace('&nbsp;&nbsp;&nbsp;&nbsp;显示','');
	name=name.replace('&nbsp;&nbsp;&nbsp;&nbsp;隐藏','');
	if(id=='undefined'){
	alert("请选择类型");
	return;
	}else{
		if(type==0){
	alert("请选择咨询分类");
	}
	}
var a = prompt('输入分类名',name);
if(a){
		$.ajax({
		url:path+"/productQuestionsAnswersSetting/edit_classifiedConsultation",
		type:"post",
		dataType:"text",
		data:{"type":type,"typeName":a,"typeId":id},
		error:function(XMLHttpRequest, textStatus, errorThrown){
       		
		},
		success:function(msg) 
		{
		if(msg=="false"){
		alert("修改失败");
		}else{
			alert("修改成功");
			changeType();
		}
           }
		});
	}
else{

	}

	
}
function showhide(){
	var id=$(".chekedClass").attr("id");
	var show=$("#"+id).attr("value");
	if(show=="1"){
		
	}else{
		show=2;
	}
		$.ajax({
		url:path+"/productQuestionsAnswersSetting/show_classifiedConsultation",
		type:"post",
		dataType:"text",
		data:{"show":show,"typeId":id},
		error:function(XMLHttpRequest, textStatus, errorThrown){
       		
		},
		success:function(msg) 
		{
		if(msg=="false"){
		alert("修改失败");
		}else{
			alert("修改成功");
			changeType();
		}
           }
		});

	
}
</script>
